<?php
namespace app\admin\model\goods;
use think\facade\Db;
use app\admin\common;

class RefundOrder{
	
	public function findRefundData($_where,$_field)
	{
		return Db::name("shop_order_refund")->alias("refund")
			->join("shop_order o","o.id=refund.order_id")
			->join("user u","u.id=refund.user_id")
			->where($_where)
			->field($_field)
			->find();	
	}
	
	public function selectRefundData($_where,$_field,$_limit,$_order)
	{
		$_data=Db::name("shop_order_refund")->alias("refund")
			->join("shop_order o","o.id=refund.order_id")
			->join("user u","u.id=refund.user_id")
			->where($_where)
			->field($_field)
			->limit(current($_limit),end($_limit))
			->order($_order)
			->select();
		return empty($_data)?:$_data->toArray();
	}
	
	public function selectRefundDataDetails($_where,$_field)
	{
		$_data=Db::name("shop_order_refund_details")
				->alias("refund")
				->join("shop_order_details d","d.id=refund.details_id")
				->join("shop_goods g","g.id=d.goods_id")
				->where($_where)
				->field($_field)
				->select();
		return empty($_data)?:$_data->toArray();
	}
	
	public function findRefund($_where,$_field){
		return Db::name("shop_order_refund")->where($_where)->field($_field)->find();
	}
	
	public function updateRefund($_up,$_where)
	{
		return Db::name("shop_order_refund")->where($_where)->update($_up);
	}
}
?>